# See LICENSE for license details.

#*****************************************************************************
# fmin.S
#-----------------------------------------------------------------------------
#
# Test f{min|max}.d instructinos.
#

#include "riscv_test.h"
#include "test_macros.h"

#ifdef N600_CFG_FPU_DOUBLE
RVTEST_RV64UF
RVTEST_CODE_BEGIN

  #-------------------------------------------------------------
  # Arithmetic tests
  #-------------------------------------------------------------

  TEST_FP_OP2_D_fmin( 2,  fmin.d, 0,        1.0,        2.5,        1.0 );
  TEST_FP_OP2_D_fmin( 3,  fmin.d, 0,    -1235.1,    -1235.1,        1.1 );
  TEST_FP_OP2_D_fmin( 4,  fmin.d, 0,    -1235.1,        1.1,    -1235.1 );
  TEST_FP_OP2_D_fmin( 5,  fmin.d, 0,    -1235.1,        NaN,    -1235.1 );
  TEST_FP_OP2_D_fmin( 6,  fmin.d, 0, 0.00000001, 3.14159265, 0.00000001 );
  TEST_FP_OP2_D_fmin( 7,  fmin.d, 0,       -2.0,       -1.0,       -2.0 );

  TEST_FP_OP2_D_fmin(12,  fmax.d, 0,        2.5,        2.5,        1.0 );
  TEST_FP_OP2_D_fmin(13,  fmax.d, 0,        1.1,    -1235.1,        1.1 );
  TEST_FP_OP2_D_fmin(14,  fmax.d, 0,        1.1,        1.1,    -1235.1 );
  TEST_FP_OP2_D_fmin(15,  fmax.d, 0,    -1235.1,        NaN,    -1235.1 );
  TEST_FP_OP2_D_fmin(16,  fmax.d, 0, 3.14159265, 3.14159265, 0.00000001 );
  TEST_FP_OP2_D_fmin(17,  fmax.d, 0,       -1.0,       -1.0,       -2.0 );

  # FMIN(sNaN, x) = x
  TEST_FP_OP2_D_fmin(20,  fmax.d, 0x10, 1.0, sNaN, 1.0);
  # FMIN(qNaN, qNaN) = canonical NaN
  TEST_FP_OP2_D_fmin(21,  fmax.d, 0x00, qNaN, NaN, NaN);

  # -0.0 < +0.0
  TEST_FP_OP2_D_fmin(30,  fmin.d, 0,       -0.0,       -0.0,        0.0 );
  TEST_FP_OP2_D_fmin(31,  fmin.d, 0,       -0.0,        0.0,       -0.0 );
  TEST_FP_OP2_D_fmin(32,  fmax.d, 0,        0.0,       -0.0,        0.0 );
  TEST_FP_OP2_D_fmin(33,  fmax.d, 0,        0.0,        0.0,       -0.0 );

  TEST_PASSFAIL

RVTEST_CODE_END

  .data
RVTEST_DATA_BEGIN

  TEST_DATA

RVTEST_DATA_END

#endif

#ifndef N600_CFG_FPU_DOUBLE
RVTEST_RV64M
RVTEST_CODE_BEGIN

j pass

TEST_PASSFAIL
RVTEST_CODE_END
  .data
RVTEST_DATA_BEGIN
  TEST_DATA

RVTEST_DATA_END
#endif
